Skip to content

Add global Registry for cross-model enum field lookup - #3

Merged
kinnell merged 1 commit into
mainfrom
registry
Feb 21, 2026
Merged

Add global Registry for cross-model enum field lookup#3
kinnell merged 1 commit into
mainfrom
registry

Conversation

@kinnell

@kinnell kinnell commented Feb 21, 2026

Copy link
Copy Markdown
Owner

Description

This PR serves to introduce an EnumFields::Registry that provides a centralized, globally-accessible index of all enum field definitions keyed by model name, enabling cross-model lookup and introspection of registered enum fields.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a globally accessible EnumFields::Registry to index enum field definitions by underscored model name, enabling cross-model lookup/introspection of registered enum fields.

Changes:

  • Added EnumFields::Registry (a hash-like store with indifferent access) plus EnumFields.registry, EnumFields.register, and EnumFields.clear_registry!.
  • Hooked EnumField#define! to automatically register every enum_field definition into the global registry.
  • Added comprehensive specs for registry behavior and ensured test isolation by clearing the registry before each example.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
spec/spec_helper.rb Clears the global registry before each spec to avoid cross-example state leakage.
spec/enum_fields/registry.spec.rb Adds coverage for registry access, key normalization, integration with enum_field, and clearing behavior.
lib/enum_fields/registry.rb Implements the new Registry store and #register behavior.
lib/enum_fields/enum_field.rb Registers definitions into the global registry during define!.
lib/enum_fields.rb Adds autoload + module-level registry helpers (registry, register, clear_registry!).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kinnell
kinnell merged commit a142eea into main Feb 21, 2026
6 checks passed
@kinnell
kinnell deleted the registry branch February 21, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants